#=========================================================================
# Copyright (C) 2022 The C++ Component Model(COMO) Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=========================================================================

project(RPCTestService CXX)

set(SERVICE_SRC_DIR ${RPC_SAMPLE_SRC_DIR}/service)
set(SERVICE_OBJ_DIR ${RPC_SAMPLE_OBJ_DIR}/service)

include_directories(
    ./
    ${INC_DIR}
    ${SERVICE_OBJ_DIR})

set(SOURCES
    main.cpp)

# import COMO component `RPCTestUnit.so` ##################
IMPORT_COMO_COMPONENT("${SAMPLES_BIN_DIR}/RPCTestUnit.so" ${SERVICE_OBJ_DIR})

IMPORT_LIBRARY(comort.so)
IMPORT_LIBRARY(libservicemanager.so)

add_executable(testRPCSrv
    ${SOURCES}
    ${GENERATED_SOURCES})
target_link_libraries(testRPCSrv comort.so libservicemanager.so)

# Dependent targets are provided by the COMO environment (SDK) and needn't
# add_dependencies to libservicemanager ...
#add_dependencies(testRPCSrv RPCTestUnit libservicemanager)

COPY(testRPCSrv ${SERVICE_OBJ_DIR}/testRPCSrv ${SAMPLES_BIN_DIR})

install(FILES
    ${SERVICE_OBJ_DIR}/testRPCSrv
    DESTINATION ${SAMPLES_BIN_DIR}
    PERMISSIONS
        OWNER_READ
        OWNER_WRITE
        OWNER_EXECUTE
        GROUP_READ
        GROUP_WRITE
        GROUP_EXECUTE
        WORLD_READ
        WORLD_EXECUTE)
